package com.wdy.po;

import java.io.Serializable;

import com.wdy.util.BasicUtil;
@SuppressWarnings({"unchecked", "serial"})
public class Park implements Comparable, Serializable {

	private Integer pid;
	private String location;
	private String note;
	private Tenement tenement;
	
	public Park() {
		super();
	}

	public Park(Integer pid, String location, String note, Tenement tenement) {
		super();
		this.pid = pid;
		this.location = location;
		this.note = note;
		this.tenement = tenement;
	}

	public Integer getPid() {
		return pid;
	}

	public void setPid(Integer pid) {
		this.pid = pid;
	}

	public String getLocation() {
		return location;
	}

	public void setLocation(String location) {
		this.location = location;
	}

	public String getNote() {
		return note;
	}

	public void setNote(String note) {
		this.note = note;
	}

	public Tenement getTenement() {
		return tenement;
	}

	public void setTenement(Tenement tenement) {
		this.tenement = tenement;
	}
/*
	@Override
	public boolean equals(Object o) {
		if(null == o) {
			return false;
		}
		if(o instanceof Park){
			Park contrastPark = (Park)o;
			Integer contrastPid = contrastPark.getPid();
			String contrastLocation = contrastPark.getLocation();
			if(this.pid.equals(contrastPid) && BasicUtil.isNullOrEmpty(this.location, contrastLocation)){
				return true;
			}
		}
		return false;
	}

	@Override
	public int hashCode() {
		return this.pid.hashCode() * this.location.hashCode();
	}
*/
	@Override
	public String toString() {
		return this.location;
	}

	public int compareTo(Object o) {
		Park contrastPark = (Park)o;
		Integer contrastPid = contrastPark.getPid();
		int orignalId = this.pid.intValue();
		int contrastId = contrastPid.intValue();
		return BasicUtil.compare(orignalId, contrastId);
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((location == null) ? 0 : location.hashCode());
		result = prime * result + ((pid == null) ? 0 : pid.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof Park))
			return false;
		final Park other = (Park) obj;
		if (location == null) {
			if (other.location != null)
				return false;
		} else if (!location.equals(other.location))
			return false;
		if (pid == null) {
			if (other.pid != null)
				return false;
		} else if (!pid.equals(other.pid))
			return false;
		return true;
	}
}
